package db

import (
	List "CSCredis/datastruct/list"
	"CSCredis/interface/server"
	"CSCredis/reply"
	"time"
)

/**
 * @Author: hejing@szlabsun.com
 * @Description:
 * @File:  db
 * @Version: 1.0.0
 * @Date: 2021/7/23 10:37
 */
type DB interface {
	Exec(client server.Client, args [][]byte) reply.Reply
	AfterClientClose(c server.Client)
	PutEntity(key string, entity *DataEntity) int
	GetEntity(key string) (*DataEntity, bool)
	GetAsString(key string) ([]byte, reply.Reply)
	Persist(key string)
	Close()
	Flush()
	GetTTLMap() Dict
	GetData() Dict
	PutIfAbsent(key string, entity *DataEntity) int
	PutIfExists(key string, entity *DataEntity) int
	Expire(key string, expireTime time.Time)
	Remove(key string)
	Removes(keys ...string) int
	// list
	getAsList(key string) (*List.LinkedList, reply.ErrorReply)
	getOrInitList(key string) (list *List.LinkedList, isNew bool, errReply reply.ErrorReply)
}
